package com.glela.platform.model.response;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.ParseException;
import java.text.SimpleDateFormat;

import com.glela.platform.model.PromotionDetail;
import com.glela.platform.model.UserPromotion;

public class ResponseCouponModel {
	private String promotionDetailName;// 优惠券名称
	private String type;// 细则类型(1.妆币2.现金券3.品牌券.4.预售券 5.商品券 6.达人激活码) 7 商品类型券
	private String amount;// 满减金额
	private String limited;// 满足条件
	private String goodsId;// 商品券关联商品ID
	private String isDiscount;// 是否折扣  0否（减免金额） 1是（折扣率）
	private String discount;// 折扣率
	private String targetSelfType;// 优惠券自主类型 0 自主 1 非自主
	private String effectTimeSlot;// 生效时间段
	private String promotionNumber;// 张数
	
	private final SimpleDateFormat normalSDF = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
	private final SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd");
	public ResponseCouponModel(UserPromotion userPromotion) {
		this.promotionDetailName = userPromotion.getPromotionDetailName();
		this.type = userPromotion.getType() + "";
		this.amount = BigDecimal.valueOf(userPromotion.getAmount()).divide(BigDecimal.valueOf(100)).setScale(0, RoundingMode.HALF_UP).toString();
		this.limited = BigDecimal.valueOf(userPromotion.getLimited()).divide(BigDecimal.valueOf(100)).setScale(0, RoundingMode.HALF_UP).toString();
		this.goodsId = userPromotion.getGoodId() + "";
		this.isDiscount = userPromotion.getIsDiscount() + "";
		this.discount = BigDecimal.valueOf(userPromotion.getDiscount()).divide(BigDecimal.valueOf(10)).setScale(1, RoundingMode.HALF_UP).toString();
		this.targetSelfType = userPromotion.getTargetSelfType() + "";
		String effectiveTime = "0000.00.00";
		String expirationTime = "0000.00.00";
		try {
			effectiveTime = sdf.format(normalSDF.parse(userPromotion.getEffectiveTime()));
			expirationTime = sdf.format(normalSDF.parse(userPromotion.getExpirationTime()));
		} catch (ParseException e) {
			
		}
		this.effectTimeSlot = effectiveTime + " - " + expirationTime;
	}
	
	public ResponseCouponModel(PromotionDetail promotionDetail) {
		this.promotionDetailName = promotionDetail.getPromotionDetailName();
		this.type = promotionDetail.getType() + "";
		this.amount = BigDecimal.valueOf(promotionDetail.getAmount()).divide(BigDecimal.valueOf(100)).setScale(0, RoundingMode.HALF_UP).toString();
		this.limited = BigDecimal.valueOf(promotionDetail.getLimited()).divide(BigDecimal.valueOf(100)).setScale(0, RoundingMode.HALF_UP).toString();
		this.goodsId = promotionDetail.getGoodId() + "";
		this.isDiscount = promotionDetail.getIsDiscount() + "";
		this.discount = BigDecimal.valueOf(promotionDetail.getDiscount()).divide(BigDecimal.valueOf(10)).setScale(1, RoundingMode.HALF_UP).toString();
		this.targetSelfType = promotionDetail.getTargetSelfType() + "";
		String effectiveTime = "0000.00.00";
		String expirationTime = "0000.00.00";
		try {
			effectiveTime = sdf.format(normalSDF.parse(promotionDetail.getEffectiveTime()));
			expirationTime = sdf.format(normalSDF.parse(promotionDetail.getExpirationTime()));
		} catch (ParseException e) {
			
		}
		this.effectTimeSlot = effectiveTime + " - " + expirationTime;
		this.promotionNumber = promotionDetail.getPromotionDetailNumber() + "张";
	}
	
	public String getPromotionDetailName() {
		return promotionDetailName;
	}
	
	public void setPromotionDetailName(String promotionDetailName) {
		this.promotionDetailName = promotionDetailName;
	}
	
	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getAmount() {
		return amount;
	}
	
	public void setAmount(String amount) {
		this.amount = amount;
	}
	
	public String getLimited() {
		return limited;
	}
	
	public void setLimited(String limited) {
		this.limited = limited;
	}
	
	public String getGoodsId() {
		return goodsId;
	}

	public void setGoodsId(String goodsId) {
		this.goodsId = goodsId;
	}

	public String getIsDiscount() {
		return isDiscount;
	}

	public void setIsDiscount(String isDiscount) {
		this.isDiscount = isDiscount;
	}

	public String getDiscount() {
		return discount;
	}

	public void setDiscount(String discount) {
		this.discount = discount;
	}

	public String getTargetSelfType() {
		return targetSelfType;
	}

	public void setTargetSelfType(String targetSelfType) {
		this.targetSelfType = targetSelfType;
	}

	public String getEffectTimeSlot() {
		return effectTimeSlot;
	}
	
	public void setEffectTimeSlot(String effectTimeSlot) {
		this.effectTimeSlot = effectTimeSlot;
	}

	public String getPromotionNumber() {
		return promotionNumber;
	}

	public void setPromotionNumber(String promotionNumber) {
		this.promotionNumber = promotionNumber;
	}
	
}
